<?php

namespace app\agent\controller\channel;

use think\facade\Db;

use app\agent\controller\Controller;
use app\agent\model\channel\Mobile as ChannelModel;
use app\agent\validate\channel\Mobile as ChannelValidate;

class Mobile extends Controller
{
    protected function initialize()
    {
        parent::initialize();
    }

    /**
     * 列表
     */
    public function list()
    {
        $model = new ChannelModel;
        $data = input('post.');
        $data['agent'] = $this->agent;
        return $model->getList($data);
    }

    /**
     * 添加
     */
    public function create()
    {
        $data = input('post.');
        $validate = new ChannelValidate;
        if (!$validate->scene('create')->check($data)) {
            return fail($validate->getError());
        }

        $model = new ChannelModel;
        $data['agent'] = $this->agent;
        return $model->create($data);
    }

    /**
     * 编辑
     */
    public function edit()
    {
        $data = input('post.');
        $validate = new ChannelValidate;
        if (!$validate->scene('edit')->check($data)) {
            return fail($validate->getError());
        }

        $model = new ChannelModel;
        $data['agent'] = $this->agent;
        return $model->edit($data);
    }

    /**
     * 删除
     */
    public function delete()
    {
        $data = input('post.');
        $model = new ChannelModel;
        $data['agent'] = $this->agent;
        return $model->delete($data);
    }
}
